<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>定位的堆叠顺序</title>
    <style>
      .box {
        position: absolute;
        top: 0;
        left: 0;
        width: 200px;
        height: 200px;
      }
      .xiongda {
        background-color: red;
        z-index: 1;
      }
      .xionger {
        background-color: green;
        left: 50px;
        top: 50px;
        /* 只有定位盒子才有z-index属性，数值越大，盒子越靠上
            如果值一样，后写的盒子靠上
            注意：z-index不能写单位
         */
        z-index: 2;
      }
      .qiangge {
        background-color: blue;
        left: 100px;
        top: 100px;
        /* 不设置z-index，默认值为auto */
      }
    </style>
  </head>
  <body>
    <div class="box xiongda">熊大</div>
    <div class="box xionger">熊二</div>
    <div class="box qiangge">光头强</div>
  </body>
</html>
